package com.gemme.gemme.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gemme.gemme.R;
import com.gemme.gemme.wode.DingDanBean;

import java.text.DecimalFormat;
import java.util.List;

public class OrderView extends RelativeLayout {

    private Context context;
    private DecimalFormat mFormat = new DecimalFormat("0.00");

    public OrderView(Context context) {
        this(context,null);
    }

    public OrderView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public OrderView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    TvEditText order_mark;
    LinearLayout ll_content;
    TextView tv_sumPrice;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.order_view,this);
        ll_content = findViewById(R.id.ll_content);
        order_mark = findViewById(R.id.order_mark);
        order_mark.setLeftText("订单备注").setRightHintText("特殊需求请标注说明联系卖家");

        tv_sumPrice = findViewById(R.id.tv_sumPrice);
       /* ll_content.addView(new SingleOrderView(context));
        ll_content.addView(new SingleOrderView(context));*/
    }

    public void setData(List<DingDanBean.DataBean.ShopProductVoListBean> shopProductVoList) {
        if(shopProductVoList == null || shopProductVoList.size() == 0)
            return;

        try {
            for (int i = 0; i < shopProductVoList.size(); i++) {
                DingDanBean.DataBean.ShopProductVoListBean shopProductVoListBean = shopProductVoList.get(i);
                SingleOrderView singleOrderView = new SingleOrderView(context);
                singleOrderView.setData(shopProductVoListBean);
                ll_content.addView(singleOrderView);
//                tv_sumPrice.setText(shopProductVoListBean.getSubTotal() + "");
            }
        }catch (Exception e){

        }
    }

    public void setSumProce(double sumProce){
        tv_sumPrice.setText("¥" + mFormat.format(sumProce));
    }
}
